package com.aba.hms.pojo;
	import java.util.Scanner;

	public class Ljr {
	    private static final int TOTAL_ROOMS = 10; // 假设有10间客房
	    private static String[] rooms = new String[TOTAL_ROOMS]; // 存储客房状态和住客信息
	    private static Scanner scanner = new Scanner(System.in);

	    public static void main(String[] args) {
	        initializeRooms(); // 初始化客房状态
	        while (true) {
	            System.out.println("\n欢迎来到酒店管理系统！");
	            System.out.println("1. 查看房间状态");
	            System.out.println("2. 选房");
	            System.out.println("3. 退房");
	            System.out.println("4. 退出系统");
	            System.out.print("请输入您的选择：");
	            int choice = scanner.nextInt();
	            scanner.nextLine(); // 清除缓冲区

	            switch (choice) {
	                case 1:
	                    displayRooms();
	                    break;
	                case 2:
	                    checkIn();
	                    break;
	                case 3:
	                    checkOut();
	                    break;
	                case 4:
	                    System.out.println("感谢使用酒店管理系统，再见！");
	                    return;
	                default:
	                    System.out.println("无效的选择，请重新输入！");
	            }
	        }
	    }

	    // 初始化客房状态
	    private static void initializeRooms() {
	        for (int i = 0; i < TOTAL_ROOMS; i++) {
	            rooms[i] = "空闲"; // 初始状态为空闲
	        }
	    }

	    // 显示所有客房状态
	    private static void displayRooms() {
	        System.out.println("\n当前房间状态：");
	        for (int i = 0; i < TOTAL_ROOMS; i++) {
	            System.out.println("房间 " + (i + 1) + ": " + rooms[i]);
	        }
	    }

	    // 住客选房并注册
	    private static void checkIn() {
	        displayRooms();
	        System.out.print("请输入要入住的房间号（1-" + TOTAL_ROOMS + "）：");
	        int roomNumber = scanner.nextInt();
	        scanner.nextLine(); // 清除缓冲区

	        if (roomNumber < 1 || roomNumber > TOTAL_ROOMS) {
	            System.out.println("房间号无效！");
	            return;
	        }

	        if (!rooms[roomNumber - 1].equals("空闲")) {
	            System.out.println("该房间已被占用！");
	            return;
	        }

	        System.out.print("请输入住客姓名：");
	        String guestName = scanner.nextLine();

	        rooms[roomNumber - 1] = guestName;
	        System.out.println("入住成功！房间 " + roomNumber + " 已分配给 " + guestName);
	    }

	    // 住客退房
	    private static void checkOut() {
	        displayRooms();
	        System.out.print("请输入要退房的房间号（1-" + TOTAL_ROOMS + "）：");
	        int roomNumber = scanner.nextInt();
	        scanner.nextLine(); // 清除缓冲区

	        if (roomNumber < 1 || roomNumber > TOTAL_ROOMS) {
	            System.out.println("房间号无效！");
	            return;
	        }

	        if (rooms[roomNumber - 1].equals("空闲")) {
	            System.out.println("该房间已经空闲！");
	            return;
	        }
	        rooms[roomNumber - 1] = "空闲";
	        System.out.println("退房成功！房间 " + roomNumber + " 已标记为空闲");
	    }
	}

